window.onload = function(){
var items = document.getElementsByName("items");
var chooseAll = document.getElementById("chooseAll");
var chooseNone = document.getElementById("chooseNone");
var inverse = document.getElementById("inverse");
var submit = document.getElementById("submit");
var button = document.getElementById("button");


chooseAll.onclick = function(){
    button.checked = true;
    for(var i=0;i<items.length;i++){
        items[i].checked = true;
    }
};

chooseNone.onclick = function(){
    button.checked = false;
    for(var i=0;i<items.length;i++){
        items[i].checked = false;
    }
};

inverse.onclick = function(){
    button.checked = true;
    for(var i=0;i<items.length;i++){
        items[i].checked = !items[i].checked;
        if(!items[i].checked){
            button.checked = false;
        }
    }
};

submit.onclick = function(){
    for(var i=0;i<items.length;i++){
        if(items[i].checked){
            console.log(items[i].value);
        }
    }
}

button.onclick = function(){
    for(var i=0;i<items.length;i++){
        items[i].checked = this.checked;
    }
}

for(var i=0;i<items.length;i++){
    items[i].onclick = function(){
        button.checked = true;
        for(var j=0;j<items.length;j++){
            if(!items[j].checked){
                button.checked = false;
                break;
            }
        }
    }
}





};

